# Contributor: Michał Polański <michal@polanski.me>
# Maintainer: Michał Polański <michal@polanski.me>
pkgname=rustic
# NOTE: do not move out of the testing repository until upstream says it's no longer beta-quality software
pkgver=0.6.1
pkgrel=0
pkgdesc="Fast, encrypted, deduplicated backups"
url="https://github.com/rustic-rs/rustic"
license="MIT OR Apache-2.0"
arch="all !s390x" # fails to build nix crate
makedepends="cargo cargo-auditable"
subpackages="
	$pkgname-bash-completion
	$pkgname-fish-completion
	$pkgname-zsh-completion
	"
source="https://github.com/rustic-rs/rustic/archive/v$pkgver/rustic-$pkgver.tar.gz"
options="net" # fetch dependencies


prepare() {
	default_prepare

	cargo fetch --target="$CTARGET" --locked
}

build() {
	cargo auditable build --frozen --release

	target/release/rustic completions bash > $pkgname.bash
	target/release/rustic completions fish > $pkgname.fish
	target/release/rustic completions zsh > $pkgname.zsh
}

check() {
	cargo test --frozen
}

package() {
	install -Dm755 target/release/$pkgname -t "$pkgdir"/usr/bin/

	install -Dm644 $pkgname.bash "$pkgdir"/usr/share/bash-completion/completions/$pkgname
	install -Dm644 $pkgname.fish "$pkgdir"/usr/share/fish/vendor_completions.d/$pkgname.fish
	install -Dm644 $pkgname.zsh "$pkgdir"/usr/share/zsh/site-functions/_$pkgname
}

sha512sums="
44b1e2be7336f74e832c33d06101b2ad1ba79123926bd00f3e4884cd49abd75e727e26636451bc393d154ec438fd9168ae9dce8bfa4ec9ffd371b89b6b426dcd  rustic-0.6.1.tar.gz
"
